package com.duanfh.RequestMapping;

import org.apache.log4j.Logger;

import java.io.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

public class MyMapping {
    private static Logger logger = Logger.getLogger(MyMapping.class);
    public static HashMap<String,String> mapping = new HashMap<String,String>();
    static{
        Properties properties = new Properties();
        File file = new File("src/main/resources/mapping.properties");
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        if(inputStream != null){
            try {
                properties.load(inputStream);
            } catch (IOException e) {
                e.printStackTrace();
            }
            Iterator<Map.Entry<Object, Object>> it = properties.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<Object, Object> entry = it.next();
                String key = (String) entry.getKey();
                String value = (String) entry.getValue();
                mapping.put(key,value);
            }
        }

    }
    public HashMap<String,String> getMapping(){
        return mapping;
    }
}
